package d1225;

import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

/*
   缓冲字节输入流：
   BufferedInputStream类：
   构造方法：
   public BufferedInputStream(InputStream in);
   成员方法：
   public int read() throws IOException
   读取到一个字节，返回的是读取到的字节，读取到文件末尾，返回-1
   public int read()(byte[] bs) throws IOException
   把读取到的字节存放在字节数组，返回的是存放到字节数组中的个数
   读取到文件末尾返回-1
   public void close();关闭资源

 */
public class a3
{
    public static void main(String[] args) {
        try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream("a.txt"))) {
            byte[] bytes = new byte[1024];
            int read;
            while ((read=bis.read(bytes))!=-1){
                System.out.println(new String(bytes,0,read));
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
